package com.samxcode.leetcode;

import java.util.HashMap;
import java.util.Map;


public class TwoSum {

    public int[] twoSum(int[] numbers, int target) {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < numbers.length; i++) {
            if (map.containsKey(target - numbers[i])) {
                int[] result = {map.get(target - numbers[i]) + 1, i + 1};
                return result;
            } else {
                map.put(numbers[i], i);
            }
        }
        return null;
    }

    
}
